<!DOCTYPE html>
<html lang="utf-8">
<head>
    <meta charset="utf-8">
<!--    <meta name="viewport" content="width=device-width, initial-scale=1.0">-->
    <title>jumpserver主机资源巡检</title>
    <style>
        body {
<!--            justify-content: center;-->
            align-items: center;
            margin: 0;
            text-align: center;
            background-color: #0d0d0d;
        }
        .container {
            width: 70%; /* 调整容器宽度 */
            text-align: center;
            margin: 0 auto;
        }
        table {
            width: auto;
            border-collapse: collapse;
            table-layout: auto; /* 自适应内容宽度 */
            margin: 0 auto;
        }
        th, td {
            border: 1px solid #dddddd;
            text-align: left;
            padding: 6px;
            word-break: break-all; /* 自动换行 */
            color: white;
        }
        th {
            background-color: #7d34a2;
            color: white;
            white-space: nowrap; /* 不换行 */
        }
        h2{
            color: white;
        }
        tr{
            background-color: #3d3d3d;
            color:white;
        }
        .progress-bar {
            width: 100%;
            background-color: #e87555;
            border-radius: 5px;
            margin-bottom: 5px;
            position: relative; /* 设置相对定位 */
        }
        .progress {
            height: 20px;
            background-color: #e87555;
            border-radius: 5px;
            text-align: center;
            color: white;
            white-space: nowrap; /* 不换行 */
            overflow: hidden; /* 隐藏溢出部分 */
            position: absolute; /* 设置绝对定位 */
            top: 0; /* 相对于父元素顶部对齐 */
            left: 0; /* 相对于父元素左侧对齐 */
            width: 100%; /* 宽度与父元素相同 */
            padding-top: 3px; /* 垂直居中 */
        }
        .percentage {
            margin-top: 5px; /* 调整百分比位置 */
        }
        .wider-column {
            width: 100%; /* 设置第二列宽度为70% */
        }
    </style>
</head>
<body>
<!--    #windows主机模板-->
    <div class="container">
        <h2>DNS-xunjian</h2>
        {% for ip, stats in dns_data.items() %}
        <table>
            <th>{{ ip }}</th>
            <tr>
                <td>CPU usage</td>
                <td class="wider-column">
                    <div class="progress-bar">
                        <div class="progress" style="width: {{ stats['cpu'] }};">{{ stats['cpu'] }}</div>
                    </div>
                    <div class="percentage">{{ stats['cpu'] }}</div>
                </td>
            </tr>
            <tr>
                <td>mem usage</td>
                <td class="wider-column">
                    <div class="progress-bar">
                        <div class="progress" style="width: {{ stats['mem'] }};">{{ stats['mem'] }}</div>
                    </div>
                    <div class="percentage">{{ stats['mem'] }}</div>
                </td>
            </tr>
            <tr>
                <td colspan="2">storage usage</td>
            </tr>
            {% for volume, usage in stats['storage'].items() %}
            <tr>
                <td>{{ volume }}</td>
                <td class="wider-column">
                    <div class="progress-bar">
                        <div class="progress" style="width: {{ usage }};">{{ usage }}</div>
                    </div>
                    <div class="percentage">{{ usage }}</div>
                </td>
            </tr>
            {% endfor %}
        </table>
        {% endfor %}
    </div>
    <div class="container">
        <h2>jumpserver-xunjian</h2>
        {% for ip, stats in data.items() %}
        <table>
            <th>{{ ip }}</th>
            <tr>
                <td>CPU usage</td>
                <td class="wider-column">
                    <div class="progress-bar">
                        <div class="progress" style="width: {{ stats['cpu'] }};">{{ stats['cpu'] }}</div>
                    </div>
                    <div class="percentage">{{ stats['cpu'] }}</div>
                </td>
            </tr>
            <tr>
                <td>mem usage</td>
                <td class="wider-column">
                    <div class="progress-bar">
                        <div class="progress" style="width: {{ stats['mem'] }};">{{ stats['mem'] }}</div>
                    </div>
                    <div class="percentage">{{ stats['mem'] }}</div>
                </td>
            </tr>
            <tr>
                <td colspan="2">storage usage</td>
            </tr>
            {% for partition, usage in stats['storage'].items() %}
            <tr>
                <td>{{ partition }}</td>
                <td class="wider-column">
                    <div class="progress-bar">
                        <div class="progress" style="width: {{ usage }};">{{ usage }}</div>
                    </div>
                    <div class="percentage">{{ usage }}</div>
                </td>
            </tr>
            {% endfor %}
        </table>
        {% endfor %}
    </div>

</body>
</html>

